module.exports = function (url, callback = () => {}, error = () => {}) {
  return new Promise((reslove, reject) => {
    var link = document.createElement("link");
    link.href = url;
    link.type = "text/css";
    link.rel = "stylesheet";
    document.head.appendChild(link);
    if (link.addEventListener) {
      link.addEventListener(
        "load",
        function () {
          callback();
          reslove();
        },
        false
      );
      link.addEventListener(
        "error",
        function () {
          error();
          reject();
        },
        false
      );
    } else if (link.attachEvent) {
      link.attachEvent("onreadystatechange", function () {
        var target = window.event.srcElement;
        if (target.readyState == "loaded") {
          callback();
          reslove();
        }
      });
    }
  });
};
